<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML>
<html lang="en-US">
<head>
	<meta charset="UTF-8">
	<title></title>
	<link rel="stylesheet" href="css/bootstrap.css" />
	<script type="text/javascript" src="js/jquery.js"></script>
	<script type="text/javascript" src="js/bootstrap.min.js"></script>
</head>
<body>
	<form action="login" class="well" style="width:320px;margin-left:auto;margin-right:auto">
		用户名：<label for="name"><input type="text" name="name"/></label>
		密码：<label for="password"><input type="password" name="password" onkeyup="sub(event)"/></label>
		<h2 style="text-align:center;">
		<button type="button"  class="btn btn-primary" data-loading-text="loading..." onclick="subs()" >提交</button>
		<a href="regret.jsp"  class="btn btn-primary" >注册</a>
		</h2>
		<script type="text/javascript">
		function sub(event){
			password=document.getElementsByName("password")[0].value;
			name=document.getElementsByName("name")[0].value;
			var code=event.keyCode;
			if(code==13&&name.length>6&&password.length>6){
				$.post("login",{name:name,password:password},function(data){
					if(data=="ok"){
						window.location='admin';
					}else{
					window.location='index.jsp?code=-1';
					}
				});
			}
		};
		function subs(){
		//$("#btn").button("loading");
			password=document.getElementsByName("password")[0].value;
			name=document.getElementsByName("name")[0].value;
			if(name.length>6&&password.length>6){
				$.post("login",{name:name,password:password},function(data){
					if(data=="ok"){
						window.location='admin';
					}else{
					window.location='index.jsp?code=-1';
					}
				});
			}
		};
		</script>
	</form>
</body>
</html>